package com.me.bigdata

import org.apache.spark.{SparkConf, SparkContext}

/**
  * 单词频次统计
  */
object ScalaWordCount {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setMaster("local").setAppName("ScalaWordCount")
    val sc = new SparkContext(conf)
    val textFile = sc.textFile(args(0))
    textFile.flatMap(_.split(" ")).filter(("" != _)).map((_, 1)).reduceByKey(_ + _).sortBy(_._2, false).saveAsTextFile(args(1))
  }
}
